<?php
require_once('bookmark_sum.php');
session_start();
do_html_header();
do_html_introduce();
do_html_login_form();
do_html_footer();
//空值判断及初始字符串判断交由js实现
if (isset($_POST['username'])&&isset($_POST['password'])&&$_POST['username']!=""&&$_POST['password']!="") {
	$username=$_POST['username'];
	$password=$_POST['password'];
	//如果在数据库中正确验证则跳转到主页面
	$conn=db_connect();
	if ($conn) {
	$result=$conn->query("select * from user where username='".$username."' and passwd='".$password."'");
	//printf($result->num_rows);
	if (@$result->num_rows==1) {
		$_SESSION['valid_user']=$username;
		printf('<script>location.href="./index.php"</script>');
	}
	else{
		echo '<script type="text/javascript">alert("用户名不正确，请登录！");</script>';
	}
}
}

?>